#include <bits/stdc++.h>
using namespace std;
int t , n , m , l , v;
int f[5];
int h[100005];
int main()
{
    freopen("detect.in" , "r" , stdin);
    freopen("detect.out" , "w" , stdout);
    cin >> t;
    for (int i = 1 ; i <= t ; i++)
        cin >> f[i];
    n = f[1];
    m = f[2];
    l = f[3];
    v = f[4];
    for (int i = 1 ; i <= n ; i++)
    {
        if(i != n)
        {
            for (int i = 1 ; i <= 3 ; i++)
                cin >> h[i];
        }
        if(i == n)
         {
            for (int i = 1 ; i <= 5 ; i++)
                 cin >> h[i];
         }
    }
    cout << 0 << " " << 0;
    return 0;
}
